<script setup>
import { useEChart } from '@/utils/echartDom'

// 使用折线图
const { chartDom: lineChartDom } = useEChart('line', {
  xData: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  yData: [820, 932, 901, 934, 1290, 1330, 1320]
})

// 使用柱状图
const { chartDom: barChartDom } = useEChart('bar', {
  xData: ['周一', '周二', '周三', '周四', '周五', '周六'],
  yData: [5, 20, 36, 10, 10, 20]
})
</script>

<template>
  <!-- 左侧 -->
  <el-col :span="18" class="leftChart">
    <!-- 农场概况 -->
    <el-row class="fameGK">
      <el-row class="ChartTitle">农场概况</el-row>
      <el-row class="ChartContent">
        <el-col :span="10" class="contentarea">
          <el-row class="content-1">268</el-row>
          <el-row class="content-2">种植面积(亩)</el-row>
        </el-col>
        <el-col :span="10" class="contentarea">
          <el-row class="content-1">98%</el-row>
          <el-row class="content-2">设备在线率</el-row>
        </el-col>
      </el-row>
    </el-row>

    <!-- 环境监测 -->
    <el-row class="fameHJ">
      <el-row class="ChartTitle">环境监测</el-row>
      <el-row class="ChartContentC">
        <div ref="lineChartDom" style="width: 100%; height: 300px;"></div>
      </el-row>
    </el-row>

    <!-- 作物生长状态 -->
    <el-row class="fameZW">
      <el-row class="ChartTitle">作物生长状态</el-row>
      <el-row class="ChartContentC">
        <div ref="barChartDom" style="width: 100%; height: 300px;"></div>
      </el-row>
    </el-row>
  </el-col>
</template>

<style scoped>
.leftChart {
  position: absolute;
  height: calc(100% - 80px);
  left: 20px;
  margin-top: 20px;
  z-index: 1;
  display: flex;
  flex-direction: column; /* 垂直排列 */
  justify-content: space-between; /* 子元素垂直居中 */
  align-items: center; /* 子元素水平居中 */
  gap: 20px;
  /* 统一控制模块间距 */

  /* 渐变背景色 从左到右 */
  background: linear-gradient(to left, #167a3d80, #38aa6278);
  /* 透明背景 */
  background-color: rgba(0, 0, 0, 0.5);
  /* 阴影 */
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
}

.ChartTitle {
  width: 280px;
  height: 30px;
  font-size: 15px;
  font-weight: bold;
  text-align: center;
  background-color: #115D2E;
  color: #4ADE80;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.contentarea {
  height: 100px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 15px;
  font-weight: bold;
  background-color: #000000;
  color: #4ADE80;
  border-radius: 10px;
}

.ChartContent {
  margin-top: 10px;
  width: 300px;
  display: flex;
  justify-content: space-between;
}

.content-1 {
  padding-top: 20px;
  justify-content: center;
  text-align: center;
  font-size: 25px;
  font-weight: bold;
}

.content-2 {
  padding-top: 20px;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.5);
}

.fameGK,
.fameHJ,
.fameZW {
  width: 300px;
  padding: 0 10px;
  border-radius: 10px;
}

.ChartContentC {
  margin-top: 10px;
  height: 200px;
  width: 300px;
  background-color: #000101;
  border-radius: 10px;
  overflow: hidden;
  /* 防止图表溢出 */
}
</style>